using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using SpoonCore2.Client;
using SpoonCore2.Message;

namespace SpoonCore2.Service.Stun
{
	class StunMessage : AbstractMessage
	{
		public enum TypeValue { Request, Response }
		public enum CommandValue { Register, Ping, Pair }

		private TypeValue _type = TypeValue.Request;
		private CommandValue _command = CommandValue.Ping;
		private SpoonIdentifier _id = SpoonIdentifier.Empty;

		public TypeValue Type
		{
			get { return _type; }
			set { _type = value; }
		}

		public CommandValue Command
		{
			get { return _command; }
			set { _command = value; }
		}

		public SpoonIdentifier Id
		{
			get { return _id; }
			set { _id = value; }
		}

		public override void GetBytes(BinaryWriter bw)
		{
			bw.Write((byte)Type);
			bw.Write((byte)Command);
		}

		public override void SetBytes(IService service, BinaryReader br)
		{
			Type = (TypeValue)br.ReadByte();
			Command = (CommandValue)br.ReadByte();
		}
	}
}
